﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Web;

namespace Transport
{
    public class GenHtml
    {
        public static string genBangGiaLT(BGTLTentity item)
        {
            string html = null;
            html += "<div class=\"test\">"
                              + "<div class=\"ice-row\">"
                                  + "<div class=\"lof-inner\">"
                                  + "<div class=\"inner_border\">"
                                      + "<h4 class=\"heading\">"
                                          + "<a target=\"_parent\" href=\"/HireCarsDetail.aspx?maDichVu=0&id=" + item.Ma_bien_so + "&malotrinh=" + item.MaLoTrinh + "\">" + item.Ten_thuong_hieu + "</a>"
                                      + "</h4>";
            html += "<div class=\"padding jshopping_padding\">"
                                        + "<div class=\"iceTip\" rel=\"\" title=\"\">"
                                            + "<a target=\"_parent\" class=\"a_car_img\" href=\"/HireCarsDetail.aspx?maDichVu=0&id=" + item.Ma_bien_so + "&malotrinh=" + item.MaLoTrinh + "\">"
                                                + "<img class=\"car_img\" src=\"template/hktransport/images/" + item.Hinhanh + "\" title=\"Time Capsule\" alt=\"Time Capsule\" width=\"195px\" height=\"150px\">"
                                            + "</a>"
                                        + "</div>"
                                        + "<div class=\"list_att\">"
                                            + "<div class=\"jshop_old_price\"><p style=\"word-wrap: break-word;\">Dòng xe: " + item.HangXe + "</p></div>"
                                            + "<div class=\"jshop_old_price\">Loại xe: " + item.So_cho + " chỗ</div>"
                                            + "<div class=\"jshop_old_price\">LT: " + item.Ten_lo_trinh + "</div>";
            if (item.Tinh_trang == "1")
            {
                html += "<div class=\"jshop_old_price\">Tình trạng: Có sẵn </div>";
            }
            else if (item.Tinh_trang == "2")
            {
                html += "<div class=\"jshop_old_price\">Tình trạng: Đang thuê</div>";
            }
            html += "<div class=\"jshop_old_price\"> Giá thuê: " + String.Format(CultureInfo.CreateSpecificCulture("en-US"), "{0:c}", item.Gia_tien) + "</div>"
                                      + "<p class=\"readmore jshop_old_price\"><a target=\"_parent\" href=\"/HireCarsDetail.aspx?maDichVu=0&id=" + item.Ma_bien_so + "&malotrinh=" + item.MaLoTrinh + "\">Xem tiếp ...</a>"
                                  + "</p>"
                                  + "</div>"
                             + "</div>"
                      + "</div>"
                      + "</div>"
                  + "</div>"
                  + "</div>";
            return html;
        }
        public static string getBangGiaNgay(BangGiaTrongNgayNew item)
        {
            string html = null;
            html += "<div class=\"test\">"
                                     + "<div class=\"ice-row\">"
                                         + "<div class=\"lof-inner\">"
                                         + "<div class=\"inner_border\">"
                                             + "<h4 class=\"heading\">"
                                                 + "<a target=\"_parent\" href=\"/HireCarsDetail.aspx?maDichVu=" + item.MaDichVu + "&id=" + item.MaXe + "\">" + item.HieuXe + "</a>"
                                             + "</h4>";
            html += "<div class=\"padding jshopping_padding\">"
                                        + "<div class=\"iceTip\" rel=\"\" title=\"\">"
                                            + "<a target=\"_parent\" class=\"a_car_img\" href=\"/HireCarsDetail.aspx?maDichVu=" + item.MaDichVu + "&id=" + item.MaXe + "\">"
                                                + "<img class=\"car_img\" src=\"template/hktransport/images/" + item.Hinhanh + "\" title=\"Time Capsule\" alt=\"Time Capsule\" width=\"195px\" height=\"150px\">"
                                            + "</a>"
                                        + "</div>"
                                        + "<div class=\"list_att\">"
                                            + "<div class=\"jshop_old_price\"><p style=\"word-wrap: break-word;\">Dòng xe: " + item.HangXe + "</p></div>"
                                            + "<div class=\"jshop_old_price\">Loại xe: " + item.LoaiXe + " chỗ</div>"
                                            +"<div class=\"jshop_old_price\">Dịch vụ: " + item.TenDichVu + "</div>";
            if (item.TinhTrangXe == "1")
            {
                html += "<div class=\"jshop_old_price\">Tình trạng: Có sẵn </div>";
            }
            else if (item.TinhTrangXe == "2")
            {
                html += "<div class=\"jshop_old_price\">Tình trạng: Đang thuê</div>";
            }
            html += "<div class=\"jshop_old_price\"> Giá thuê ngày: " + String.Format(CultureInfo.CreateSpecificCulture("en-US"),"{0:c}",item.GiaTien) + "</div>"
                                      + "<p class=\"readmore jshop_old_price\"><a target=\"_parent\" href=\"/HireCarsDetail.aspx?maDichVu=" + item.MaDichVu + "&id=" + item.MaXe + "\">Xem tiếp ...</a>"
                                  + "</p>"
                                  + "</div>"
                             + "</div>"
                      + "</div>"
                      + "</div>"
                  + "</div>"
                  + "</div>";
            return html;
        }
        public static string Pagination(int cur_page, int total, string action)
        {
            bool previous_btn = true;
            bool next_btn = true;
            bool first_btn = true;
            bool last_btn = true;
            int no_of_paginations = total / 10;
            if (total % 10 <= 10)
            {
                no_of_paginations += 1;
            }
            int start_loop, end_loop;

            if (cur_page >= 7)
            {
                start_loop = cur_page - 3;
                if (no_of_paginations > cur_page + 3)
                {
                    end_loop = cur_page + 3;
                }
                else if (cur_page <= no_of_paginations && cur_page > no_of_paginations - 6)
                {
                    start_loop = no_of_paginations - 6;
                    end_loop = no_of_paginations;
                }
                else
                {
                    end_loop = no_of_paginations;
                }
            }
            else
            {
                start_loop = 1;
                if (no_of_paginations > 7)
                {
                    end_loop = 7;
                }
                else
                {
                    end_loop = no_of_paginations;
                }
            }

            string htmlPagination = "<ul>";
            if (first_btn && cur_page > 1)
            {
                htmlPagination += "<li class='active'><a href='./" + action + "&page=1'>Đầu</a></li>";
            }
            else if (first_btn)
            {
                htmlPagination += "<li class='inactive'>Đầu</li>";
            }

            if (previous_btn && cur_page > 1)
            {
                int pre = cur_page - 1;
                htmlPagination += "<li class='active'><a href='./" + action + "&page=" + pre + "'>Lui</a></li>";
            }
            else if (previous_btn)
            {
                htmlPagination += "<li class='inactive'>Lui</li>";
            }

            for (int i = start_loop; i <= end_loop; i++)
            {

                if (cur_page == i)
                {
                    htmlPagination += "<li style='color:#fff;background-color:#7FB308;' class='active'><a style='color:#fff;' href='./product_manage.htm?page=" + i + "'>" + i + "</a></li>";
                }
                else
                {
                    htmlPagination += "<li class='active'><a href='./" + action + "&page=" + i + "'>" + i + "</a></li>";
                }
            }

            if (next_btn && cur_page < no_of_paginations)
            {
                int nex = cur_page + 1;
                htmlPagination += "<li class='active'><a href='./" + action + "&page=" + nex + "'>Tiếp</a></li>";
            }
            else if (next_btn)
            {
                htmlPagination += "<li class='inactive'>Tiếp</li>";
            }

            if (last_btn && cur_page < no_of_paginations)
            {
                htmlPagination += "<li class='active'><a href='./" + action + "&page=" + no_of_paginations + "'>Cuối</a></li>";
            }
            else if (last_btn)
            {
                htmlPagination += "<li class='inactive'>Cuối</li>";
            }
            htmlPagination += "</ul><input type='text' class='goto' size='1' style='margin-top:1px;margin-left:10px;'/><a  id='go_btn' class='go_button'>Go</a><span class='total' a='" + no_of_paginations + "'>Page <b>" + cur_page + "</b> of <b>" + no_of_paginations + "</b></span>";

            return htmlPagination;
        }
    }
}